using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;

namespace Data_Access_Tier
{
	public class HRM_SALARY_BYDEPARTMENTData : DatabaseObjectBase
	{
		public HRM_SALARY_BYDEPARTMENTData()
		{
			Initialize(true);
		}
		public HRM_SALARY_BYDEPARTMENTData(Boolean newConnection)
		{
			Initialize(newConnection);
		}

		public Int32 HRM_SALARY_BYDEPARTMENT_Insert(String EmployeeCode, Decimal M1, Decimal M2, Decimal M3, Decimal M4, Decimal M5, Decimal M6, Decimal M7, Decimal M8, Decimal M9, Decimal M10, Decimal M11, Decimal M12, Decimal TotalSalary)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.InsertCommand = new SqlCommand("HRM_SALARY_BYDEPARTMENT_Insert");
				_dbadapter.InsertCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.InsertCommand.Connection = _dbconn;
				_trans = _dbconn.BeginTransaction();
				_dbadapter.InsertCommand.Transaction = _trans;
				_dbadapter.InsertCommand.Parameters.Clear();
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M1", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M2", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M3", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M4", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M5", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M6", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M7", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M8", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M9", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M10", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M11", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@M12", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@TotalSalary", SqlDbType.Money));
				_dbadapter.InsertCommand.Prepare();
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.InsertCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlMoney M1SQL = M1;
				_dbadapter.InsertCommand.Parameters["@M1"].Value = M1SQL;
				SqlMoney M2SQL = M2;
				_dbadapter.InsertCommand.Parameters["@M2"].Value = M2SQL;
				SqlMoney M3SQL = M3;
				_dbadapter.InsertCommand.Parameters["@M3"].Value = M3SQL;
				SqlMoney M4SQL = M4;
				_dbadapter.InsertCommand.Parameters["@M4"].Value = M4SQL;
				SqlMoney M5SQL = M5;
				_dbadapter.InsertCommand.Parameters["@M5"].Value = M5SQL;
				SqlMoney M6SQL = M6;
				_dbadapter.InsertCommand.Parameters["@M6"].Value = M6SQL;
				SqlMoney M7SQL = M7;
				_dbadapter.InsertCommand.Parameters["@M7"].Value = M7SQL;
				SqlMoney M8SQL = M8;
				_dbadapter.InsertCommand.Parameters["@M8"].Value = M8SQL;
				SqlMoney M9SQL = M9;
				_dbadapter.InsertCommand.Parameters["@M9"].Value = M9SQL;
				SqlMoney M10SQL = M10;
				_dbadapter.InsertCommand.Parameters["@M10"].Value = M10SQL;
				SqlMoney M11SQL = M11;
				_dbadapter.InsertCommand.Parameters["@M11"].Value = M11SQL;
				SqlMoney M12SQL = M12;
				_dbadapter.InsertCommand.Parameters["@M12"].Value = M12SQL;
				SqlMoney TotalSalarySQL = TotalSalary;
				_dbadapter.InsertCommand.Parameters["@TotalSalary"].Value = TotalSalarySQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.InsertCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_SALARY_BYDEPARTMENT_Insert: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_SALARY_BYDEPARTMENT_Insert: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.InsertCommand != null)
					_dbadapter.InsertCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_SALARY_BYDEPARTMENT_Update(String EmployeeCode, Decimal M1, Decimal M2, Decimal M3, Decimal M4, Decimal M5, Decimal M6, Decimal M7, Decimal M8, Decimal M9, Decimal M10, Decimal M11, Decimal M12, Decimal TotalSalary)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_SALARY_BYDEPARTMENT_Update");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M1", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M2", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M3", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M4", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M5", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M6", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M7", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M8", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M9", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M10", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M11", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M12", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@TotalSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Prepare();
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.UpdateCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlMoney M1SQL = M1;
				_dbadapter.UpdateCommand.Parameters["@M1"].Value = M1SQL;
				SqlMoney M2SQL = M2;
				_dbadapter.UpdateCommand.Parameters["@M2"].Value = M2SQL;
				SqlMoney M3SQL = M3;
				_dbadapter.UpdateCommand.Parameters["@M3"].Value = M3SQL;
				SqlMoney M4SQL = M4;
				_dbadapter.UpdateCommand.Parameters["@M4"].Value = M4SQL;
				SqlMoney M5SQL = M5;
				_dbadapter.UpdateCommand.Parameters["@M5"].Value = M5SQL;
				SqlMoney M6SQL = M6;
				_dbadapter.UpdateCommand.Parameters["@M6"].Value = M6SQL;
				SqlMoney M7SQL = M7;
				_dbadapter.UpdateCommand.Parameters["@M7"].Value = M7SQL;
				SqlMoney M8SQL = M8;
				_dbadapter.UpdateCommand.Parameters["@M8"].Value = M8SQL;
				SqlMoney M9SQL = M9;
				_dbadapter.UpdateCommand.Parameters["@M9"].Value = M9SQL;
				SqlMoney M10SQL = M10;
				_dbadapter.UpdateCommand.Parameters["@M10"].Value = M10SQL;
				SqlMoney M11SQL = M11;
				_dbadapter.UpdateCommand.Parameters["@M11"].Value = M11SQL;
				SqlMoney M12SQL = M12;
				_dbadapter.UpdateCommand.Parameters["@M12"].Value = M12SQL;
				SqlMoney TotalSalarySQL = TotalSalary;
				_dbadapter.UpdateCommand.Parameters["@TotalSalary"].Value = TotalSalarySQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_SALARY_BYDEPARTMENT_Update: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_SALARY_BYDEPARTMENT_Update: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_SALARY_BYDEPARTMENT_Disable(String EmployeeCode, ref Boolean Enabled)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_SALARY_BYDEPARTMENT_Disable");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@enabled", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Prepare();
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.UpdateCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				_dbadapter.UpdateCommand.Parameters["@enabled"].Direction = ParameterDirection.Output;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_SALARY_BYDEPARTMENT_Disable: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_SALARY_BYDEPARTMENT_Disable: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_SALARY_BYDEPARTMENT_Delete(String EmployeeCode)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.DeleteCommand = new SqlCommand("HRM_SALARY_BYDEPARTMENT_Delete");
				_dbadapter.DeleteCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.DeleteCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.DeleteCommand.Transaction = _trans;

				_dbadapter.DeleteCommand.Parameters.Clear();
				_dbadapter.DeleteCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.DeleteCommand.Prepare();
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.DeleteCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.DeleteCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_SALARY_BYDEPARTMENT_Delete: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_SALARY_BYDEPARTMENT_Delete: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.DeleteCommand != null)
					_dbadapter.DeleteCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_SALARY_BYDEPARTMENT_Save(String EmployeeCode, Decimal M1, Decimal M2, Decimal M3, Decimal M4, Decimal M5, Decimal M6, Decimal M7, Decimal M8, Decimal M9, Decimal M10, Decimal M11, Decimal M12, Decimal TotalSalary)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_SALARY_BYDEPARTMENT_Save");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M1", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M2", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M3", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M4", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M5", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M6", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M7", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M8", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M9", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M10", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M11", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@M12", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@TotalSalary", SqlDbType.Money));
				_dbadapter.UpdateCommand.Prepare();
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.UpdateCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				SqlMoney M1SQL = M1;
				_dbadapter.UpdateCommand.Parameters["@M1"].Value = M1SQL;
				SqlMoney M2SQL = M2;
				_dbadapter.UpdateCommand.Parameters["@M2"].Value = M2SQL;
				SqlMoney M3SQL = M3;
				_dbadapter.UpdateCommand.Parameters["@M3"].Value = M3SQL;
				SqlMoney M4SQL = M4;
				_dbadapter.UpdateCommand.Parameters["@M4"].Value = M4SQL;
				SqlMoney M5SQL = M5;
				_dbadapter.UpdateCommand.Parameters["@M5"].Value = M5SQL;
				SqlMoney M6SQL = M6;
				_dbadapter.UpdateCommand.Parameters["@M6"].Value = M6SQL;
				SqlMoney M7SQL = M7;
				_dbadapter.UpdateCommand.Parameters["@M7"].Value = M7SQL;
				SqlMoney M8SQL = M8;
				_dbadapter.UpdateCommand.Parameters["@M8"].Value = M8SQL;
				SqlMoney M9SQL = M9;
				_dbadapter.UpdateCommand.Parameters["@M9"].Value = M9SQL;
				SqlMoney M10SQL = M10;
				_dbadapter.UpdateCommand.Parameters["@M10"].Value = M10SQL;
				SqlMoney M11SQL = M11;
				_dbadapter.UpdateCommand.Parameters["@M11"].Value = M11SQL;
				SqlMoney M12SQL = M12;
				_dbadapter.UpdateCommand.Parameters["@M12"].Value = M12SQL;
				SqlMoney TotalSalarySQL = TotalSalary;
				_dbadapter.UpdateCommand.Parameters["@TotalSalary"].Value = TotalSalarySQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_SALARY_BYDEPARTMENT_Save: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_SALARY_BYDEPARTMENT_Save: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_SALARY_BYDEPARTMENT_GetList()
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_SALARY_BYDEPARTMENT_GetList");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Prepare();
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_SALARY_BYDEPARTMENT_GetList: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_SALARY_BYDEPARTMENT_Get(String EmployeeCode)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_SALARY_BYDEPARTMENT_Get");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@EmployeeCode", SqlDbType.VarChar, 20));
				_dbadapter.SelectCommand.Prepare();
				SqlString EmployeeCodeSQL = EmployeeCode;
				_dbadapter.SelectCommand.Parameters["@EmployeeCode"].Value = EmployeeCodeSQL;
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_SALARY_BYDEPARTMENT_Get: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
	}
}
